﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;

namespace WebpartSample.UpdtPan
{
    public partial class UpdtPanUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("name");
                dt.Columns.Add("dept");
                dt.Columns.Add("Gender");
                dt.Rows.Add("George", "IT","Male");
                dt.Rows.Add("Livingston", "Traffic","Male");

                dt.Rows.Add("Kushbu", "Acting", "Female");
                dt.Rows.Add("Paxton", "Business Man", "Male");
                dif.DataSource = dt;
                dif.DataBind();
            }
        }

        protected void dd_Click(object sender, EventArgs e)
        {
            //{
            //    SPSite oS = SPContext.Current.Site;
            //    SPWeb ow = SPContext.Current.Web;
            //    Label1.Text = "Cclist -" + ow.Lists["Cclist"].GetItemById(1)["Chfld"];
            //    Label2.Text = "WorksVotes -" + ow.Lists["WorksVotes"].GetItemById(33)["dd"];
            //    SPListItem ip = ow.Lists["WorksVotes"].GetItemById(33);
            //    ip["dd"] = "1499";
            //    ow.AllowUnsafeUpdates = true;
            //    ip.Update();
            //    ow.AllowUnsafeUpdates = false;
            //}
        }

        protected void dif_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                GridView HeaderGrid = (GridView)sender;
                GridViewRow HeaderGridRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Edit);
                TableCell HeaderCell = new TableCell();
                HeaderCell.Text = "Department";
                HeaderCell.ColumnSpan = 2;
                HeaderGridRow.Cells.Add(HeaderCell);

                HeaderCell = new TableCell();

                HeaderCell.Text = "Employee";

             

                HeaderGridRow.Cells.Add(HeaderCell);


                dif.Controls[0].Controls.AddAt(0, HeaderGridRow);

            }
        }

        protected void dif_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void hdi_Click(object sender, EventArgs e)
        {
            hdi.Text = "Anand";
        }
    }
}
